package com.ruoyi.source.service.impl;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.source.api.domain.SrcBatchNum;
import com.ruoyi.source.domain.vo.SrcBatchNumVo;
import com.ruoyi.source.mapper.SrcBatchNumMapper;
import com.ruoyi.source.mapper.SrcCropInfoMapper;
import com.ruoyi.source.mapper.SrcProductMapper;
import com.ruoyi.source.service.ISrcBatchNumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-31
 */
@Service
public class SrcBatchNumServiceImpl extends ServiceImpl<SrcBatchNumMapper,SrcBatchNum> implements ISrcBatchNumService
{
    @Autowired
    private SrcCropInfoMapper srcCropInfoMapper;
    @Autowired
    private SrcProductMapper srcProductMapper;
    /**
     * 查询【请填写功能名称】
     * 
     * @param batchId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SrcBatchNum selectSrcBatchNumByBatchId(Long batchId)
    {
        return baseMapper.selectById(batchId);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param srcBatchNum 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SrcBatchNumVo> selectSrcBatchNumList(SrcBatchNum srcBatchNum)
    {
        return baseMapper.selectSrcBatchNumList(srcBatchNum);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param srcBatchNum 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertSrcBatchNum(SrcBatchNum srcBatchNum) {
        srcBatchNum.setCreateTime(DateUtils.getNowDate());
        srcBatchNum.setCreateBy(SecurityUtils.getUsername());
        srcBatchNum.setRemark(srcBatchNum.getRemark());
        return baseMapper.insert(srcBatchNum);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param srcBatchNum 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateSrcBatchNum(SrcBatchNum srcBatchNum) {
        srcBatchNum.setUpdateTime(DateUtils.getNowDate());
        srcBatchNum.setUpdateBy(SecurityUtils.getUsername());
        return baseMapper.updateById(srcBatchNum);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param batchIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSrcBatchNumByBatchIds(Long[] batchIds) {
        return baseMapper.deleteBatchIds(Arrays.asList(batchIds));
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param batchId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSrcBatchNumByBatchId(Long batchId) {
        return baseMapper.deleteById(batchId);
    }

    @Override
    public List<Map<String, Object>> getGoodsList(String goodsType) {
        if (goodsType.equals("0")){
            return srcCropInfoMapper.getGoodsList();
        }else {
            return srcProductMapper.getGoodsList();
        }
    }
}
